package com.tl.web.controller.api;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tl.common.annotation.Log;
import com.tl.common.core.controller.BaseController;
import com.tl.common.core.domain.AjaxResult;
import com.tl.common.enums.BusinessType;
import com.tl.app.domain.AppLeave;
import com.tl.app.service.IAppLeaveService;
import com.tl.common.core.page.TableDataInfo;

/**
 * 留言板Controller
 * 
 * @author suhp
 * @date 2024-06-21
 */
@RestController
@RequestMapping("/api/leave")
public class ApiLeaveController extends BaseController
{
    @Autowired
    private IAppLeaveService appLeaveService;

    /**
     * 查询留言板列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AppLeave appLeave)
    {
        startPage();
        appLeave.setUserId(getUserId());
        List<AppLeave> list = appLeaveService.selectAppLeaveList(appLeave);
        return getDataTable(list);
    }


    /**
     * 新增留言板
     */
    @Log(title = "留言板", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody AppLeave appLeave)
    {
    	appLeave.setUserId(getUserId());
    	appLeave.setCreateBy(getUsername());
        return toAjax(appLeaveService.insertAppLeave(appLeave));
    }
    

}
